package com.eat.fish_service.controller.wx;


import com.eat.common_utils.R;
import com.eat.fish_service.entity.Dao.Expert;
import com.eat.fish_service.entity.ExpertQuery;
import com.eat.fish_service.service.ExpertService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LWB
 * @since 2022-03-21
 */

@RestController("wxExpertController")
@RequestMapping("/wx/expert")
@CrossOrigin
@Api(tags ="微信端专家接口")
public class ExpertController {

    @Autowired
    private ExpertService expertService;

    @ApiOperation(value = "微信端新增专家")
    @PostMapping("addexpert")
    public R uploadDiseaseFishPic(@RequestBody @ApiParam(name = "expert", value = "专家信息", required = false) Expert expert){
        return expertService.addExpert(expert);
    }

    @ApiOperation(value = "微信端上传资质二，返回图片路径，添加专家的时候调用")
    @PostMapping("addqualificationOnePic")
    public R addqualificationOnePic(MultipartFile pic){
        return expertService.addqualificationOnePic(pic);
    }

    @ApiOperation(value = "微信端上传资质三，返回图片路径，添加专家的时候调用")
    @PostMapping("addqualificationTwoPic")
    public R addqualificationTwoPicPic(MultipartFile pic){
        return expertService.addqualificationTwoPic(pic);
    }

    //条件查询鱼百科带分页文件数据
    @ApiOperation(value = "微信端条件查询专家带分页数据")
    @PostMapping("getexpert/{current}/{size}")
    public R pageExpertCondition(@PathVariable
                                 @ApiParam(name = "current", value = "当前页", required = true) Long current,
                                 @PathVariable
                                 @ApiParam(name = "size", value = "每页显示条数", required = true)  Long size,
                                 @RequestBody(required = false)
                                 @ApiParam(name = "ExpertQuery", value = "查询对象条件，专家的介绍和学历模糊查询，专家名字等值查询，时间范围查询", required = false) ExpertQuery expertQuery) {

        return expertService.pageExpertCondition(current, size, expertQuery);
    }

    //根据id查询专家数据
    @ApiOperation(value = "根据id查询专家数据")
    @GetMapping("getExpert/{expertId}")
    public R getExpert(@PathVariable @ApiParam(name = "expertId", value = "专家类Id", required = true) String expertId) {
        return expertService.getExpert(expertId);
    }
}

